const curRow = window.storage.getItem('question/curRow')
console.log(JSON.stringify(curRow))
const state = {
  selectedQuestions: [],
  // 删除对话框是否显示
  delDialogVisible: false,
  curRow,
  // 是否删除选中列
  delSelected: false
}
const mutations = {
  selectQuestions (state, questions) {
    state.selectedQuestions = questions
  },
  // 改变对话框的状态
  changeDelDialog (state, visible) {
    state.delDialogVisible = visible
  },
  // 正在操作的行
  operateCurRow (state, curRow) {
    state.curRow = curRow
    window.storage.setItem('question/curRow', curRow)
  },
  // 设置是否删除选中
  setDelSelected (state, delSelected) {
    state.delSelected = delSelected
  }
}

const actions = {
  delRow ({ commit }, row) {
    commit('operateCurRow', row)
    commit('changeDelDialog', true)
    commit('setDelSelected', false)
  },
  delSelected ({ commit }) {
    commit('changeDelDialog', true)
    commit('setDelSelected', true)
  },
  editRow ({ commit, root }, row) {
    commit('operateCurRow', row)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
